<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions" >
<h:head>
	<title>Add Employee</title>
</h:head>
<h:body>
	<h:link value="PERSONAL HOME" outcome="index" />
 	<h:form id="form">
	<p:panel id="panelNewEmployee" header="New employee">  
        <p:messages id="msgs"/>
			
        <h:panelGrid columns="3">
			<h:outputLabel for="name" value="*Name: "></h:outputLabel>
			<p:inputText id="name" value="#{addEmployee.employee.name}" maxlength="45"
				required="true" requiredMessage="Please enter the name." label="Name">
			</p:inputText>
			<p:message for="name" display="icon"/> 	
				
			<h:outputLabel for="surname" value="*Surname: "></h:outputLabel>
			<p:inputText id="surname" value="#{addEmployee.employee.surname}" maxlength="45"
				required="true" requiredMessage="Please enter the surname." label="Surname">
			</p:inputText>
			<p:message for="surname" display="icon"/> 
				
			<h:outputLabel for="email" value="*Email: "></h:outputLabel>
			<p:inputText id="email" value="#{addEmployee.employee.email}"
				required="true" requiredMessage="Please enter the email." maxlength="45"
				validatorMessage="Please enter a valid email!" label="Email">
				<f:validateRegex pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
			</p:inputText>
			<p:message for="email" display="icon"/> 
				
			<h:outputLabel for="password" value="*Password: "></h:outputLabel>
			<p:password id="password" value="#{addEmployee.employee.password}" maxlength="255"
				required="true" requiredMessage="Please enter the password." label="Password">
			</p:password>
			<p:message for="password" display="icon"/>		
		</h:panelGrid>
			
		<p:commandButton id="buttonAddEmployee" update="panelNewEmployee" value="Add employee"
			action="#{addEmployee.addEmployee()}" />
	</p:panel>
	</h:form>
</h:body>
</html>